﻿package 
{
	import flash.utils.Timer;
	

	public class FrameTimer extends Timer
	{
		// Properties /////////////////////////////////////////////////////////////////
		
		/**
		 * Stores the frame rate value.
		 * @private
		 */
		public var _fps:Number;
		
		// Constructor ////////////////////////////////////////////////////////////////
		
		/**
		 * Creates a new FrameRateTimer instance.
		 * 
		 * @param fps The frame rate value for the FrameRateTimer. If this
		 *         value is smaller than 0, 24 will be used as a default.
		 */
		public function FrameTimer(fps:Number)
		{
			_fps = fps;
			super((1000 / _fps), 0);
			
			
			
			
		}
		
		public function changeFPS(fps:int):void
		{
			_fps = fps;
			this.delay = 1000 / fps;
		}
		// Public Methods /////////////////////////////////////////////////////////////
		
		/**
		 * Returns the frame rate of the FrameTimer.
		 * 
		 * @return The frame rate of the FrameTimer.
		 */
		public function getFrameRate():int
		{
			return _fps;
		}
		public function dispose():void
		{
			this.stop();
			
		}
	}
}